﻿using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Collider2D))]
public class TriggerProp : MonoBehaviour
{

    public enum PropType
    {
        Damage,
        Cure
    }

    public string targetTag = "Player";
    public PropType type = PropType.Damage;
    public float value;

    private Collider2D _collider;
    // Use this for initialization
    void Start()
    {
        _collider = GetComponent<Collider2D>();
        if (_collider != null)
        {
            if (!_collider.isTrigger)
            {
                _collider.isTrigger = true;
            }
        }
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == targetTag)
        {
            switch (type)
            {
                case PropType.Damage:
                    other.SendMessage("Damage", value);
                    break;
                case PropType.Cure:
                    other.SendMessage("Cure", value);
                    break;
            }
        }
        gameObject.SetActive(false);
    }
}
